#ifdef BMP085

#include <Adafruit_BMP085.h>
Adafruit_BMP085 bmp;

void UserPlugin_BMP_Init(void)
{
  bmp.begin();
}

void UserPlugin_BMP_Command(int Par1, int Par2)
{
  if(Par1 == 160) bmpread(Par2);
}

/*********************************************************************************************\
 * Barometric pressure sensor BMP085 (I2C device)
 * Based on work by "Intensivus"
 \*********************************************************************************************/
void bmpread(byte Par2)
{
  unsigned long customEvent;
  unsigned long temp;
  unsigned long pressure;

  UserVar[Par2-1] = bmp.readTemperature();
  //minus 100K om alleen de nauwkeurigheid over te houden. 
  //de daadwerkelijke luchtdruk is dan onderstaande uitkomst + 1000.
  UserVar[Par2] = (bmp.readPressure()-100000);

  customEvent=float2event(UserVar[Par2-1], Par2 -1, CMD_VARIABLE_EVENT);
  userPluginSendEvent(customEvent);

  customEvent=float2event(UserVar[Par2], Par2, CMD_VARIABLE_EVENT);
  userPluginSendEvent(customEvent);

}
#endif

